package com.mofang.ticketing.common.core.enums.base;

import com.mofang.ticketing.common.core.enums.EnumVO;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

/**
 * @author ChenDongDong
 * @version 1.0
 * @description 附件类型枚举
 * @createDate 2022/10/8 16:07
 */
@Getter
@AllArgsConstructor
public enum AttachmentStatusEnum {
    /**
     * 失效
     */
    INVALID(0, "失效"),
    /**
     * 有效
     */
    VALID(1, "有效"),
    ;

    private int key;
    private String value;

    /**
     * 根据key 获取value 值
     *
     * @param key key
     * @return 值
     */
    public static String getValueByKey(int key) {
        for (AttachmentStatusEnum h : AttachmentStatusEnum.values()) {
            if (h.getKey() == key) {
                return h.getValue();
            }
        }
        return "";
    }

    /**
     * 获取枚举集合
     *
     * @return 枚举集合
     */
    public static List<EnumVO> getKeyValueList() {
        return Arrays.stream(AttachmentStatusEnum.values())
                .map(s -> new EnumVO(s.getKey(), s.getValue()))
                .collect(Collectors.toList());
    }
}


